import React, { Component } from 'react';
import { connect } from 'dva';
import { Form, Collapse } from 'antd';
import AccountForm from './hdForms/AccountForm';

@connect(({ db }) => ({ db }))
@Form.create()
class AccountManager extends Component {
  // 展开卡片的时候,根据是哪一项来具体执行不同的函数
  callback = key => {
    //如果是账户被展开
    if (key == 1) {
      const { dispatch } = this.props;
      const { serverUserInfo } = this.props.db;
      dispatch({
        type: 'db/getUserInfo',
      });
    }
  };

  render() {
    const Panel = Collapse.Panel;
    const { serverUserInfo } = this.props.db;
    return (
      <Collapse onChange={this.callback} style={{ marginLeft: 10, marginTop: 50 }}>
        <Panel header="账户管理" key="1">
          <AccountForm serverUserInfo={serverUserInfo} />
        </Panel>
      </Collapse>
    );
  }
}
export default AccountManager;
